home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / keypres2.zip / KEYPRESS.ASM < prev    next >
Assembly Source File  |  1987-11-14  |  2KB  |  74 lines

  1. ;keypress.com, disassembled via DASM and commented
  2. ; by    David Kirschbaum
  3. ;    Toad Hall
  4. ;(Why won't people distribute source for simple things like this?  Sigh ...)
  5. ;
  6.     PAGE    ,132
  7. CodeSeg    SEGMENT BYTE PUBLIC 'code'
  8.     ASSUME    CS:CodeSeg
  9.     ASSUME    SS:CodeSeg
  10.     ASSUME    DS:CodeSeg
  11.  
  12. ;notice no ORG so we can access the FCB
  13.  
  14. H00000    DB    128 DUP(?)        ;FCB beginning
  15. CmdLine    DB    128 DUP(?)        ;DOS FCB command line
  16.  
  17. KeyPress    PROC    FAR
  18.     ASSUME    ES:CodeSeg
  19. Start:
  20.     MOV    AH,07H
  21.     INT    21H
  22.     CMP    AL,00H
  23.     JNE    GotKey
  24.     MOV    AH,07H
  25.     INT    21H
  26.     XOR    AL,AL        ;Return value 0
  27.     MOV    AH,4CH        ;Terminate process
  28.     INT    21H        ;Terminate
  29.  
  30. ;check out possible key inputs
  31. GotKey:
  32.     CMP    AL,'A' 
  33.     JC    Skp11C        ;below
  34.     CMP    AL,'Z'
  35.     JNBE    Skp11C        ;upper case
  36.     ADD    AL,20H        ;lowercase it
  37. Skp11C:
  38.     MOV    AH,AL
  39.     MOV    DH,' '
  40.     XOR    DL,DL
  41.     XOR    CH,CH            ;clear msb
  42.     MOV    CL,CmdLine        ;cmd line length
  43.     JCXZ    Exit14C            ;no command line
  44.     MOV    SI,0081H        ;let's check out the whole thing
  45. Lup12D:
  46.     LODSB                ;snarf cmd line char
  47.     CMP    AL,DH            ;space?
  48.     JNE    ChkKey            ;nope, go process it
  49.     LOOP    Lup12D            ;gobble spaces
  50.     XOR    DL,DL            ;failed, return a 0
  51.     JMP    SHORT Exit14C        ; and exit
  52.  
  53. ChkKey:
  54.     CMP    AL,'A'            ;see if alphabetic char
  55.     JC    Skp142            ; must be a digit
  56.     CMP    AL,'Z'            ;
  57.     JNBE    Skp142            ; ok, a letter
  58.     ADD    AL,20H            ;change to uppercase char
  59. Skp142:
  60.     INC    DL            ;bump return value
  61.     CMP    AL,AH
  62.     JE    Exit14C            ;done
  63.     LOOP    Lup12D            ;check them all
  64.     XOR    DL,DL            ;no legal entry, return a 0
  65. Exit14C:
  66.     MOV    AL,DL            ;return val in AL
  67.     MOV    AH,4CH            ;terminate proces
  68.     INT    21H
  69. KeyPress    ENDP
  70.  
  71. ;    DB    14 DUP(?)        ;some sort of garbage
  72. CodeSeg    ENDS
  73.     END    KeyPress
  74.